function hgChangeLeftWidth() {
	var ovcol2Width = getStyle('.holygrail .col2', 'width');
	ovcol2Width = ovcol2Width.substring(0,ovcol2Width.indexOf('em'));

	var nvcol2Width = prompt("Current Value is: " + ovcol2Width + " New Value:", "");
	nvcol2Width = parseInt(nvcol2Width);
	if (!isNaN(nvcol2Width))
	{
		var theDifference = nvcol2Width - parseInt(ovcol2Width);
		
		var ovcol1wrapRight = getStyle('.holygrail .col1wrap', 'right');
		ovcol1wrapRight = ovcol1wrapRight.substring(0,ovcol1wrapRight.indexOf('em'));
		
		var ovcol1Margin = getStyle('.holygrail .col1', 'margin');
		var ovcol1MarginSplit = ovcol1Margin.split(" ");
		var ovcol1MarginLeft = ovcol1MarginSplit[3].substring(0,ovcol1MarginSplit[3].indexOf('em'));
		
		var ovcolleftLeft = getStyle('.holygrail .colleft', 'left');
		ovcolleftLeft = ovcolleftLeft.substring(0,ovcolleftLeft.indexOf('em'));

		setStyle('.holygrail .col1wrap', 'right', (parseInt(ovcol1wrapRight) + parseInt(theDifference)) + 'em');
		setStyle('.holygrail .col1', 'marginLeft', (parseInt(ovcol1MarginLeft) + parseInt(theDifference)) + 'em');
		setStyle('.holygrail .col2', 'width', (parseInt(ovcol2Width) + parseInt(theDifference)) + 'em');
		setStyle('.holygrail .colleft', 'left', (parseInt(ovcolleftLeft) + parseInt(theDifference)) + 'em');
	}
}

function hgChangeRightWidth() {
	var ovcolmidMarginLeft = getStyle('.holygrail .colmid', 'marginLeft');
	ovcolmidMarginLeft = ovcolmidMarginLeft.substring(0,ovcolmidMarginLeft.indexOf('em'));

	var nvcolmidMarginLeft = prompt("Current Value is: " + ovcolmidMarginLeft + " New Value:", "");
	nvcolmidMarginLeft = parseInt(nvcolmidMarginLeft);
	if (!isNaN(nvcolmidMarginLeft))
	{
		var theDifference = nvcolmidMarginLeft - parseInt(ovcolmidMarginLeft);
		
		var ovcolleftLeft = getStyle('.holygrail .colleft', 'left');
		ovcolleftLeft = ovcolleftLeft.substring(0,ovcolleftLeft.indexOf('em'));
		
		var ovcol3Width = getStyle('.holygrail .col3', 'width');
		ovcol3Width = ovcol3Width.substring(0,ovcol3Width.indexOf('em'));
		
		var ovcol1Margin = getStyle('.holygrail .col1', 'margin');
		var ovcol1MarginSplit = ovcol1Margin.split(" ");
		var ovcol1MarginRight = ovcol1MarginSplit[1].substring(0,ovcol1MarginSplit[3].indexOf('em'));

		setStyle('.holygrail .colmid', 'marginLeft', (parseInt(ovcolmidMarginLeft) - parseInt(theDifference)) + 'em');
		setStyle('.holygrail .colleft', 'left', (parseInt(ovcolleftLeft) + parseInt(theDifference)) + 'em');
		setStyle('.holygrail .col3', 'width', (parseInt(ovcol3Width) + parseInt(theDifference)) + 'em');
		setStyle('.holygrail .col1', 'marginRight', (parseInt(ovcol1MarginRight) + parseInt(theDifference)) + 'em');
	}
}

function getStyle(strCssSelector, strCssRule){
	/*Curent limitations:
		- Only takes value it finds first
	*/

	var j=0;
	var i=0;

	while (j < document.styleSheets.length)
	{
		while (i < document.styleSheets[0].cssRules.length)
		{
			if (document.styleSheets[0].cssRules[i].selectorText == strCssSelector){
				var oldValue = document.styleSheets[0].cssRules[i].style[strCssRule];
				if(oldValue != null){
					return oldValue;
				}
				else {
					return null;
				}
			}
			else {
				i++
			}
		}
		j++
	}

	return null;
}

function setStyle(strCssSelector, strCssRule, strValue){
	/*Curent limitations:
		- Only takes value it finds first
	*/

	var j=0;
	var i=0;

	while (j < document.styleSheets.length)
	{
		while (i < document.styleSheets[0].cssRules.length)
		{
			if (document.styleSheets[0].cssRules[i].selectorText == strCssSelector){
				document.styleSheets[0].cssRules[i].style[strCssRule] = strValue;
				return;
			}
			else {
				i++
			}
		}
		j++
	}

	return null;
}

function insertImg(){
	var body, newimg;

	// get all LIs in imagelist, loop over them 
	body=document.getElementsByTagName('body')[0];
	
	newimg=document.createElement('img');
	//newimg.style.display='block';
	newimg.src='http://www.tasi.ac.uk/images/photo-sharing-camera.jpg';
	//newimg.class='photo';
	body.appendChild(newimg)
}

function showWindow() {
	el = document.getElementById("ace");
	el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
}